{% extends 'base.html' %}
{% load static %}

{% block title %}个人资料{% endblock %}

{% block extra_css %}
<style>
    .profile-container {
        max-width: 800px;
        margin: 2rem auto;
        padding: 2rem;
    }
    
    .profile-card {
        background: linear-gradient(135deg, rgba(0, 0, 0, 0.8) 0%, rgba(30, 30, 60, 0.9) 100%);
        backdrop-filter: blur(15px);
        border-radius: 15px;
        padding: 2rem;
        color: white;
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
        border: 2px solid;
        border-image: linear-gradient(135deg, rgba(255, 255, 255, 0.4), rgba(100, 150, 255, 0.6)) 1;
    }
    
    .profile-header {
        display: flex;
        align-items: center;
        gap: 2rem;
        margin-bottom: 2rem;
        padding-bottom: 2rem;
        border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    }
    
    .profile-avatar {
        position: relative;
    }
    
    .profile-avatar img, .profile-avatar .default-avatar {
        width: 120px;
        height: 120px;
        border-radius: 50%;
        border: 4px solid #6496ff;
        box-shadow: 0 0 20px rgba(100, 150, 255, 0.5);
        object-fit: cover;
    }
    
    .profile-avatar .default-avatar {
        background: linear-gradient(135deg, #667eea, #764ba2);
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 48px;
        font-weight: bold;
        color: white;
    }
    
    .profile-level {
        position: absolute;
        bottom: -5px;
        right: -5px;
        background: linear-gradient(45deg, #ff6b35, #f7931e);
        color: white;
        border-radius: 50%;
        width: 40px;
        height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 16px;
        font-weight: bold;
        border: 3px solid #fff;
    }
    
    .profile-info h1 {
        margin: 0 0 0.5rem 0;
        background: linear-gradient(135deg, #00d4ff, #6496ff, #ffffff);
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
        background-clip: text;
        font-size: 2.5rem;
    }
    
    .profile-stats {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        gap: 1.5rem;
        margin-bottom: 2rem;
    }
    
    .stat-card {
        background: rgba(255, 255, 255, 0.1);
        border-radius: 10px;
        padding: 1.5rem;
        text-align: center;
        border: 1px solid rgba(255, 255, 255, 0.2);
    }
    
    .stat-value {
        font-size: 2rem;
        font-weight: bold;
        color: #6496ff;
        margin-bottom: 0.5rem;
    }
    
    .stat-label {
        color: rgba(255, 255, 255, 0.8);
        font-size: 0.9rem;
    }
    
    .profile-actions {
        display: flex;
        gap: 1rem;
        flex-wrap: wrap;
    }
    
    .btn {
        padding: 0.75rem 1.5rem;
        border-radius: 8px;
        text-decoration: none;
        font-weight: bold;
        transition: all 0.3s ease;
        border: 2px solid;
        display: inline-block;
    }
    
    .btn-primary {
        background: linear-gradient(135deg, #6496ff, #00d4ff);
        border-color: #6496ff;
        color: white;
    }
    
    .btn-primary:hover {
        background: linear-gradient(135deg, #00d4ff, #6496ff);
        transform: translateY(-2px);
        box-shadow: 0 5px 15px rgba(100, 150, 255, 0.4);
    }
    
    .btn-secondary {
        background: rgba(255, 255, 255, 0.1);
        border-color: rgba(255, 255, 255, 0.3);
        color: white;
    }
    
    .btn-secondary:hover {
        background: rgba(255, 255, 255, 0.2);
        border-color: rgba(255, 255, 255, 0.5);
        color: white;
    }
    
    .exp-section {
        margin-top: 1rem;
    }
    
    .exp-bar {
        width: 100%;
        height: 12px;
        background: rgba(0, 0, 0, 0.3);
        border-radius: 6px;
        overflow: hidden;
        border: 1px solid rgba(100, 150, 255, 0.3);
        margin-bottom: 0.5rem;
    }
    
    .exp-fill {
        height: 100%;
        background: linear-gradient(90deg, #00ff88, #00cc6a);
        border-radius: 5px;
        transition: width 0.3s ease;
        box-shadow: 0 0 10px rgba(0, 255, 136, 0.5);
    }
    
    .exp-text {
        color: #00ff88;
        font-size: 0.9rem;
        font-weight: bold;
        text-align: center;
    }
</style>
{% endblock %}

{% block content %}
<div class="profile-container">
    <div class="profile-card">
        <div class="profile-header">
            <div class="profile-avatar">
                {% if user.profile.avatar %}
                    <img src="{{ user.profile.avatar.url }}" alt="用户头像">
                {% else %}
                    <div class="default-avatar">{{ user.username|first|upper }}</div>
                {% endif %}
                <div class="profile-level">{{ user.profile.level|default:"1" }}</div>
            </div>
            
            <div class="profile-info">
                <h1>{{ user.username }}</h1>
                <p style="color: rgba(255, 255, 255, 0.8); margin: 0;">{{ user.profile.bio|default:"这个用户很神秘，什么都没有留下..." }}</p>
                
                <div class="exp-section">
                    <div class="exp-bar">
                        <div class="exp-fill" style="width: {{ user.profile.exp_percentage|default:"25" }}%;"></div>
                    </div>
                    <div class="exp-text">经验值: {{ user.profile.exp|default:"250" }}/{{ user.profile.next_level_exp|default:"1000" }}</div>
                </div>
            </div>
        </div>
        
        <div class="profile-stats">
            <div class="stat-card">
                <div class="stat-value">{{ user.profile.battles_won|default:"0" }}</div>
                <div class="stat-label">胜利场次</div>
            </div>
            <div class="stat-card">
                <div class="stat-value">{{ user.profile.battles_total|default:"0" }}</div>
                <div class="stat-label">总对战数</div>
            </div>
            <div class="stat-card">
                <div class="stat-value">{{ user.profile.ranking|default:"未排名" }}</div>
                <div class="stat-label">当前排名</div>
            </div>
            <div class="stat-card">
                <div class="stat-value">{{ user.date_joined|date:"Y-m-d" }}</div>
                <div class="stat-label">加入时间</div>
            </div>
        </div>
        
        <div class="profile-actions">
            <a href="{% url 'accounts:edit_profile' %}" class="btn btn-primary">
                <i class="fas fa-edit"></i> 编辑资料
            </a>
            <a href="{% url 'accounts:change_password' %}" class="btn btn-secondary">
                <i class="fas fa-key"></i> 修改密码
            </a>
            <a href="{% url 'battles:battle_list' %}" class="btn btn-secondary">
                <i class="fas fa-sword"></i> 我的对战
            </a>
            <a href="{% url 'codes:code_list' %}" class="btn btn-secondary">
                <i class="fas fa-code"></i> 我的代码
            </a>
        </div>
    </div>
</div>
{% endblock %}